
if ( CLIENT ) then
	SWEP.Author				= "CSE - Night-Eagle"
	SWEP.Contact			= "gmail sedhdi"
	SWEP.Purpose			= ""
	SWEP.Instructions		= ""
	SWEP.PrintName			= "CSE M249"
	SWEP.Instructions		= "Hold use and right-click to change firemodes."
	SWEP.Slot				= 2
	SWEP.SlotPos			= 0
	SWEP.IconLetter			= "z"
	
	SWEP.ViewModelFlip		= false
	
	killicon.AddFont("cse_m249","CSKillIcons",SWEP.IconLetter,Color(255,80,0,255))
end

if ( SERVER ) then
	AddCSLuaFile( "shared.lua" )
end


SWEP.Base				= "cse_base_a"

SWEP.Spawnable			= true
SWEP.AdminSpawnable		= true

SWEP.ViewModel			= "models/weapons/v_mach_m249para.mdl"
SWEP.WorldModel			= "models/weapons/w_mach_m249para.mdl"
SWEP.HoldType = "ar2"

SWEP.Weight				= 5
SWEP.AutoSwitchTo		= false
SWEP.AutoSwitchFrom		= false

SWEP.Primary.Sound			= Sound("Weapon_M249.Single")
SWEP.Primary.Recoil			= 0
SWEP.Primary.Unrecoil		= 7
SWEP.Primary.Damage			= 29
SWEP.Primary.NumShots		= 1
SWEP.Primary.Cone			= 0
SWEP.Primary.ClipSize		= 350
SWEP.Primary.Delay			= 0.09 //Don't use this, use the tables below!
SWEP.Primary.DefaultClip	= 6000 //Always set this 1 higher than what you want.
SWEP.Primary.Automatic		= true //Don't use this, use the tables below!
SWEP.Primary.Ammo			= "smg1"

SWEP.Secondary.ClipSize		= -1
SWEP.Secondary.DefaultClip	= -1
SWEP.Secondary.Automatic	= false
SWEP.Secondary.Ammo			= "none"

//Firemode configuration

SWEP.IronSightsPos = Vector(-4.49,-2,2.15)
SWEP.IronSightsAng = Vector(.00001,-.06,.00001)

SWEP.data = {}
SWEP.mode = "auto" //The starting firemode
SWEP.data.newclip = false //Do not change this




SWEP.data.auto = {}
SWEP.data.auto.Delay = .09
SWEP.data.auto.Cone = 0.01
SWEP.data.auto.ConeZoom = 0.005

//End of configuration


function SWEP:Reload()
	if SERVER and self.Owner:GetFOV() ~= 90 then
		self.Owner:SetFOV(90,.3)
	end
	
	if self.Owner:GetFOV() ~= 90 then
		self.Owner:SetFOV(self.data.zoomfov,.3)
		self:SetIronsights(false)
	end
	
	self.Weapon:DefaultReload(ACT_VM_RELOAD)
end

function SWEP:Think()
	if SinglePlayer() then self.data.singleplayer(self) end
end

function SWEP:PrimaryAttack()
	if ( !self:CanPrimaryAttack() ) then return end
	
	if CLIENT then
		self.xhair.loss = self.xhair.loss + self.Primary.Recoil
	end
	
	--self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
	self.Weapon:SetNextPrimaryFire( CurTime() + self.data[self.mode].Delay )
	
	self.Weapon:EmitSound(self.Primary.Sound)
	self:TakePrimaryAmmo( 1 )
	
	self.Owner:ViewPunch( Angle( math.Rand(-0.2,-0.1) * self.Primary.Recoil, math.Rand(-0.1,0.1) *self.Primary.Recoil, 0 ) )

	if self.Owner:GetFOV() == 90 then
		--self:ShootBullet( 1, 1, self.data[self.mode].Cone )
		self:CSShootBullet( self.Primary.Damage, self.Primary.Recoil, self.Primary.NumShots, self.data[self.mode].Cone )
	else
		--self:ShootBullet( 1, 1, self.data[self.mode].ConeZoom )
		self:CSShootBullet( self.Primary.Damage, self.Primary.Recoil, self.Primary.NumShots, self.data[self.mode].ConeZoom )
	end
end
